package com.qiangesoft.im.controller;

import com.qiangesoft.im.pojo.dto.ImGroupUserDTO;
import com.qiangesoft.im.pojo.vo.ResultInfo;
import com.qiangesoft.im.pojo.vo.SysUserVo;
import com.qiangesoft.im.service.IImGroupUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 群成员 前端控制器
 * </p>
 *
 * @author qiangesoft
 * @date 2024-02-07
 */
@Api(tags = "群成员")
@RestController
@RequestMapping("/im/groupUser")
public class ImGroupUserController {

    @Autowired
    private IImGroupUserService groupUserService;

    @PostMapping
    @ApiOperation(value = "添加群成员")
    public ResultInfo<Void> addGroupUser(@RequestBody ImGroupUserDTO groupUserDTO) {
        groupUserService.addGroupUser(groupUserDTO);
        return ResultInfo.ok();
    }

    @DeleteMapping
    @ApiOperation(value = "删除群成员")
    public ResultInfo<Void> removeGroupUser(@RequestBody ImGroupUserDTO groupUserDTO) {
        groupUserService.removeGroupUser(groupUserDTO);
        return ResultInfo.ok();
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "群成员列表")
    public ResultInfo<List<SysUserVo>> listGroupUser(@PathVariable Long id) {
        return ResultInfo.ok(groupUserService.listGroupUser(id));
    }

}

